<template>
    <div>
        <van-nav-bar title="搜索" left-text="返回" left-arrow @click-left="() => { $router.push('/home/sy') }" />

        <van-search v-model="value" shape="round" background="#eb4450" placeholder="请输入搜索关键词"
            @update:model-value="changed" />
        <van-cell-group>
            <router-link :to="'/detail/' + item.goods_id" v-for="item in searched">
                <van-cell :title="item.goods_name" />
            </router-link>
        </van-cell-group>

    </div>
</template>

<script setup>
import { ref } from 'vue'
import { qsearchApi } from '../request/api'
import _ from 'lodash'
const searched = ref([])
const changed = _.debounce((query) => {
    qsearchApi(query).then(res => {
        console.log('搜索', res)
        searched.value = res.data.message
    })
})
</script>

<style lang="scss" scoped></style>